1. Field of the Invention
The present invention relates to the field of computer programming, and more particularly to methods, systems, and computer program products for programmatically enforcing referential integrity constraints when modifying links or associations between class instances (including, but not limited to, associations which are specified in structured documents such as XML Metadata Interchange, or “XMI”, documents).
2. Description of the Related Art
The Meta Object Facility (“MOP”) Specification (which is hereby incorporated herein by reference) defines a simple meta-metamodel with sufficient semantics to describe metamodels in various domains. MOF is a standard of the Object Management Group. (Version 1.3 of the MOE Specification, dated Apr. 3, 2000, is available on the Internet from the Object Management Group.) The importance of having a meta-metamodel odd framework is to allow for the integration of metamodels across domains, which is necessary for integrating tools and applications across the life cycle using common semantics.
The MOF specification states that an association defines a classification over a set of links, through a relationship between Classifiers. A “link”, in this statement, is an instance of an association denoting a connection between object instances of the Classifiers of the Association. The definition of an association requires two “AssociationEnds”. FIG. 1A shows the Unified Modeling Language (“UML”) representation of an Association, and FIG. 1B shows the UML representation of an AssociationEnd, according to the MOF Association structure. (UML is a standard of the Object Management Group, and is described in “UML Toolkit”, H. Eriksson, M. Penker, published by John Wiley and Sons, 1997. Refer to this publication, or to the UML Specification, for a description of the notation used in FIGS. 1A and 1B. Version 1.3 of the UML Specification, dated Mar. 1, 2000, is available on the Internet from the Object Management Group. http://www.omg.org/technology/documents/formal/unified_modeling_language.htm.)
An association and its link are directional. For example, a link of <x1, y1> is different from <y1, x1>. While the MOF specification describes in detail the structure of the Association and its AssociationEnds, it does not specify how to perform the updating of each link and the maintaining of the other end for a given AssociationEnd instance. Without any specifics on these topics, the specification is missing important information that is required to maintain referential integrity among instances of Classifiers. Referential integrity is an extremely important concept within an application because it ensures that the links between Class instances point to the correct Class instances. For example, if a Department class has a link to an Employee class such that a department could have multiple employees, then adding an employee to a department while maintaining referential integrity would ensure that the link to the department instance from the employee instance pointed to the correct department to which the employee was just added. However, this referential integrity support is not defined in the MOF Specification, nor do the inventors know of any other modeling framework that provides this referential integrity support. (Note that the present invention is not limited to use with metamodels described using MOF. MOF is discussed herein merely as a representative example of a modeling framework which enables specifying links or associations between instances of classes.)
FIG. 2 illustrates the association between Department and Employee classes using UML notation. An Association 215 exists between instances of Department class 205 and Employee class 225. From an instance of Department class 205, the department's employees (which are instances of Employee class 225) can be located by navigating the association 215. This navigation is indicated by the arrowhead 235, and will return zero or more employees, as indicated by the multiplicity of this end of the association (as shown at 220). Or, from an instance of Employee class 225, the employee's department (which is an instance of Department class 205) can be located by navigating the association 215 in the inverse direction. This navigation is indicated by the arrowhead 230, and will return one and only one department, as indicated by the multiplicity of this end of the association (as shown at 210).
A structured notation known as the XML Metadata Interchange, or “XMT”, has been defined as a way to exchange metadata information, such as descriptions of data models. XMI is an extension of the Extensible Markup Language, or “XML”, which is a standard from the World Wide Web Consortium (“W3C”) (See “Extensible Markup Language (XML) 1.0”, W3C Recommendation Feb. 1998, 2nd edition 6 Oct. 2000, which is available on the Internet from the W3C, for more information on XML. XMI is a standard of the Object Management Group. Version 1.1 of the XMI Specification, dated Nov. 11, 2000, is available on the Internet at the Web page of the Object Management Group.) FIG. 9 provides an XMI document containing a metadata specification of the Department and Employee class and link information represented in FIG. 2. Note that this XMI document specifies both the “employees” association end (shown at 220 in FIG. 2), which has a multiplicity of zero to many, and the “department” end (shown at 210 in FIG. 2), which has a multiplicity of one to one. (See elements 920 and 930, respectively.)
When adding an employee to a department without a referential integrity implementation, the employee instance would not be pointing to the department instance in which it was contained. Currently, the only way to solve this problem would be to place logic in the application to maintain the links between Classifier instances. Writing this type of complex link maintenance logic is time-consuming and error-prone. However, both ends of each association must be maintained in order to ensure that the resulting data model is accurate. With reference to the department and employees example, this means (for example) that each time an employee's department link is modified, the application programmer must also provide logic for locating and modifying the department's link to this employee. While the department and employees example is a relatively simple data model, many data models have many associations among classes, and thus manually coding the logic to maintain the links can greatly increase the complexity of the application program and easily leads to unmaintainable code. As a result, a MOF application (or an application using another analogous modeling framework) could have invalid pointers between instances of its Classifiers.
Accordingly, what is needed is a technique for programmatically enforcing referential integrity constraints when modifying links or associations between class instances.